package com.SwaggerTest.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger2.mappers.ServiceModelToSwagger2Mapper;
@EnableSwagger2
@Configuration
public class SwaggerConfig {


    @Bean
    public Docket createRestApi() {
        System.out.println("createRestApi is ok");
        return new Docket(DocumentationType.SWAGGER_2)
                .genericModelSubstitutes(DeferredResult.class)
                .groupName("Group0")
                .useDefaultResponseMessages(true)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.SwaggerTest.Controller"))
                .build()
                .apiInfo(apiInfo());

    }

    private ApiInfo apiInfo() {

        Contact ct = new Contact("TESTDEV", "http://localhost:7020/swagger-ui.html", "379753498@qq.com");

        return new ApiInfoBuilder()
                .title("Bridge_ForTestDev") // 任意，请稍微规范点
                .description("数据检测接口查询工具") // 任意，请稍微规范点
                .termsOfServiceUrl("http://localhost/bridge/api") // 将“url”换成自己的ip:port
                .version("1.2.1")
                .contact(ct)
                .build();
    }



}
